package com.project.utils.pagination;
/**
 * <p>Title: DBDialect.java</p>
 * <p>Description: 定义数据库的类型的实现类</p>
 * <p>Copyright: </p>
 * <p>Company: </p>
 * <p>createTime:2012-6-11 下午6:39:39</p>
 * @author xwf
 * @version 1.0
 */
public class DBDialect extends Dialect {

	@Override
	public String getOracleString(String sql, int offset, int limit) {

		sql = sql.trim();
		StringBuffer pagingSelect = new StringBuffer(sql.length() + 100);

		pagingSelect
		.append("select * from ( select row_.*, rownum rownum_ from ( ");

		pagingSelect.append(sql);
		
		pagingSelect.append(" ) row_ where rownum <= ").append(offset + limit)
			 .append(") where rownum_ > ").append(offset);

		return pagingSelect.toString();
	}
	
	@Override
	public String getMysqlString(String sql, int offset, int limit) {

		sql = sql.trim();
		StringBuffer pagingSelect = new StringBuffer(sql.length() + 100);

		pagingSelect.append(sql);

		pagingSelect.append(" limit ").append(offset)
				.append(" ,").append(limit);

		return pagingSelect.toString();
	}
}